package com.zsc.wxm.ysh.anjo.security;

import com.zsc.wxm.ysh.anjo.result.Result;
import com.zsc.wxm.ysh.anjo.utils.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 描述：
 *
 * @author playmaker
 * @since 2021/2/6 15:55
 */
@Slf4j
public class UnAuthEntryPoint implements AuthenticationEntryPoint {
    @Override
    public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
        log.error("未认证异常", e);
        ResponseUtil.response(httpServletResponse, Result.error(e.getMessage()));
    }
}
